import 'package:flutter/material.dart';
import 'package:house_rental/widgets/page_content.dart';

class LoginPage extends StatefulWidget {
  const LoginPage({super.key});

  @override
  State<LoginPage> createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
  bool showPassword = false;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('登录'),
          centerTitle: true,
          backgroundColor: Colors.green,
        ),
        body: SafeArea(
          minimum: EdgeInsets.all(20),
          child: ListView(children: [
            TextField(
              decoration: InputDecoration(
                labelText: '用户名', hintText: '请输入用户名',
                // 未获得焦点下划线设为灰色
                enabledBorder: UnderlineInputBorder(
                  borderSide: BorderSide(color: Colors.grey),
                ),
                //获得焦点下划线设为蓝色
                focusedBorder: UnderlineInputBorder(
                  borderSide: BorderSide(color: Colors.green),
                ),
              ),
            ),
            Padding(padding: EdgeInsets.all(5)),
            TextField(
              decoration: InputDecoration(
                  labelText: '密码',
                  hintText: '请输入密码',
                  // 未获得焦点下划线设为灰色
                  enabledBorder: UnderlineInputBorder(
                    borderSide: BorderSide(color: Colors.grey),
                  ),
                  //获得焦点下划线设为蓝色
                  focusedBorder: UnderlineInputBorder(
                    borderSide: BorderSide(color: Colors.green),
                  ),
                  suffixIcon: IconButton(
                    icon: Icon(
                        showPassword ? Icons.visibility_off : Icons.visibility),
                    onPressed: () {
                      setState(() {
                        showPassword = !showPassword;
                      });
                    },
                  )),
              obscureText: !showPassword,
            ),
            Padding(padding: EdgeInsets.all(10)),
            ElevatedButton(
              onPressed: () {},
              child: Text('登录'),
              style: ButtonStyle(
                  backgroundColor:
                      MaterialStateProperty.all(Color(0xFF4CAF50))),
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text('没有账号，'),
                TextButton(
                    onPressed: () {
                      Navigator.pushReplacementNamed(context, '/register');
                    },
                    child: Text(
                      '去注册',
                      style: TextStyle(color: Colors.green),
                    ))
              ],
            )
          ]),
        ));
  }
}
